﻿// Decompiled with JetBrains decompiler
// Type: Netick.Connection
// Assembly: Netick, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 6726ECA1-C773-4CF7-8952-E81B30D93B52
// Assembly location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.dll
// XML documentation location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.xml

using System;
using System.Runtime.CompilerServices;

#nullable disable
namespace Netick;

public class Connection
{
  internal readonly int _id;
  internal CustomizableSocketTransport _transport;
  internal int _mtu = 1000;
  internal IEndPoint _address;
  internal double _lastRecvTime;
  internal double _lastSendTime;
  internal double _lastMtuTime;
  internal int _mtuLevel;
  internal bool _mtuDone;
  internal int _mtuSends = 20;

  public int Id => this._id;

  public CustomizableSocketTransport Transport => this._transport;

  public int Mtu => this._mtu;

  public IEndPoint Address => this._address;

  public Connection(CustomizableSocketTransport transport, int index)
  {
    this._transport = transport;
    this._id = index;
  }

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  internal void Init(IEndPoint address)
  {
    this._mtu = 500;
    this._mtuDone = false;
    this._mtuSends = 20;
    this._mtuLevel = 0;
    this._address = address;
    this._lastRecvTime = this._transport._currentTime;
    this._lastSendTime = this._lastRecvTime;
  }

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public void Send(BitBuffer buffer) => this._transport.SendPayload(this, buffer);

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public void Send(IntPtr ptr, int len) => this._transport.SendPayload(this, ptr, len);
}
